<extend name="./public/frame.html"/>
<block name="content">
    <form class="layui-form" action="{:url('edit')}" method="post" enctype="multipart/form-data">
        <input type="hidden" name="car_id" value="{$info.car_id}"/>
        <input type="hidden" name="driver_id" value="{$info.driver_id}"/>
        <table class="layui-table">
            <tr>
                <td style="width: 118px;text-align: center;">真实姓名</td>
                <td><input type="text" name="driver_name" id="driver_name" class="layui-input" lay-verify="required" value="{$info['driver_name']}"></td>
            </tr>
            <tr>
                <td style="text-align: center;">身份证</td>
                <td><input type="text" name="id_number" id="id_number" class="layui-input" lay-verify="required" value="{$info['id_number']}"></td>
            </tr>
            <tr>
                <td style="text-align: center;">初次领证日期</td>
                <td><input type="text" name="license_time" id="license_time" class="layui-input" lay-verify="required" value="{$info['license_time']}"></td>
            </tr>
            <tr>
                <td style="text-align: center;">驾驶证有效期</td>
                <td><input type="text" name="valid_time" id="valid_time" class="layui-input" lay-verify="required" value="{$info['valid_time']}"></td>
            </tr>
            <tr>
                <td style="text-align: center;">车辆颜色</td>
                <td><input type="text" name="color" id="color" class="layui-input" lay-verify="required" value="{$info['color']}"></td>
            </tr>
            <tr>
                <td style="text-align: center;">所有人姓名</td>
                <td><input type="text" name="owner" id="owner" class="layui-input" lay-verify="required" value="{$info['owner']}"></td>
            </tr>
            <tr>
                <td style="text-align: center;">行驶证车牌号</td>
                <td><input type="text" name="car_plate" id="car_plate" class="layui-input" lay-verify="required" value="{$info['car_plate']}"></td>
            </tr>
            <tr>
                <td style="text-align: center;">发动机号</td>
                <td><input type="text"name="vin" id="vin" class="layui-input" lay-verify="required" value="{$info['vin']}"></td>
            </tr>
            <tr>
                <td style="text-align: center;">车辆识别代码</td>
                <td><input type="text"name="car_vin" id="car_vin" class="layui-input" lay-verify="required" value="{$info['car_vin']}"></td>
            </tr>
            <tr>
                <td style="text-align: center;">车辆注册日期</td>
                <td><input type="text"name="register_at" id="register_at" class="layui-input" lay-verify="required" value="{$info['register_at']}"></td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="text-align: center;">身份证(正面)</td>
                            <td style="text-align: center;">身份证(反面)</td>
                            <td style="text-align: center;">驾驶证</td>
                            <td style="text-align: center;">行驶证</td>
                            <td style="text-align: center;">车辆图片</td>
                        </tr>
                        <tr>
                            <td class="layer-photos-demo" style="text-align: center;"><img id="upload-CarBrand-00" src="{$info['id_front']}" style="width: 150px;height: 75px;">
                                <input name="id_front" id="id_front" type="hidden" value="<?php echo $info['id_front'];?>">
                                <button type="button" style="display: flex;position: relative;left: 30%" class="layui-btn uploads"  id="upload-CarBrand-0" >上传图片</button>
                            </td>

                            <td class="layer-photos-demo" style="text-align: center;"><img id="upload-CarBrand-11"  src="{$info['id_back']}" style="width: 150px;height: 75px;">
                                <input name="id_back" id="id_back"  type="hidden" value="<?php echo $info['id_back'];?>">
                                <button type="button" style="display: flex;position: relative;left: 30%" class="layui-btn uploads"  id="upload-CarBrand-1" >上传图片</button>
                            </td>

                            <td class="layer-photos-demo" style="text-align: center;"><img id="upload-CarBrand-22"  src="{$info['license']}" style="width: 150px;height: 75px;">
                                <input name="license"  id="license" type="hidden" value="<?php echo $info['license'];?>">
                                <button type="button" style="display: flex;position: relative;left: 30%" class="layui-btn uploads"  id="upload-CarBrand-2" >上传图片</button>
                            </td>
                            <td class="layer-photos-demo" style="text-align: center;"><img id="upload-CarBrand-33" src="{$info['permit']}" style="width: 150px;height: 75px;">
                                <input name="permit" id="permit"  type="hidden" value="<?php echo $info['permit'];?>">
                                <button type="button" style="display: flex;position: relative;left: 30%" class="layui-btn uploads"  id="upload-CarBrand-3" >上传图片</button>
                            </td>
                            <td class="layer-photos-demo" style="text-align: center;"><img id="upload-CarBrand-44"  src="{$info['body_img']}" style="width: 150px;height: 75px;">
                                <input name="body_img" id="body_img" type="hidden" value="<?php echo $info['body_img'];?>">
                                <button type="button" style="display: flex;position: relative;left: 30%" class="layui-btn uploads"  id="upload-CarBrand-4" >上传图片</button>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button class="layui-btn" lay-submit="" lay-filter="submit">提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </td>
            </tr>
        </table>
    </form>
    <script>
        layui.use(['form','laydate','upload'], function () {
            form = layui.form
                ,laydate = layui.laydate
                ,upload = layui.upload;
            layer.photos({
                photos: '.layer-photos-demo'
                ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                ,tab: function(pic, layero){
                    var str = "<div style='text-align: center'>"+pic.alt+"</div>";
                    layero.prepend(str);
                }
            });
            //常规用法
            laydate.render({
                elem: '#license_time'
            });
            laydate.render({
                elem: '#valid_time'
            });
            laydate.render({
                elem: '#register_at'
            });
            var k;
            var id_str;
            var num;
            upload.render({
                elem: '.uploads'//这个就等同于点击
                ,url: '/admin/Upload/uploadImg'

                ,before: function(obj){
                    id_str=this.item.context.id;

                    //预读本地文件示例，不支持ie8
                }
                ,done:  function(res){ //上传后的回调
                    var arr=id_str.split("-");
                    var num=arr[2];
                    if(res.status == 1){
                        $("#"+id_str+num+"").css('display','');
                        $("#"+id_str+num+"").attr('src',res.data.file); //点击后的大图
                        $("#"+id_str+num+"").attr('layer-src',res.data.file_thumb); //小图
                        num=parseInt(num);
                        switch (num){
                            case 0:$("#id_front").val(res.data.file);break;
                            case 1:$("#id_back").val(res.data.file);break;
                            case 2:$("#license").val(res.data.file);break;
                            case 3:$("#permit").val(res.data.file);break;
                            case 4:$("#body_img").val(res.data.file);break;
                        }
                        layer.msg('上传成功',{icon: 1});
                    }else{
                        layer.msg(res.msg);
                    }
                }
                ,error: function(e){
                    console.log(e)
                }
            });
        });
    </script>
</block>